<?php

namespace app\common\model;

use think\Model;

class SystemMessage extends Model
{
    protected $name = 'system_message';
    
    // 自动写入时间戳
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'type_text',
        'createtime_text'
    ];
    
    public function getTypeTextAttr($value, $data)
    {
        $types = [
            'goods' => '商品订单',
            'travel' => '文旅订单',
            'service' => '服务订单'
        ];
        return isset($types[$data['type']]) ? $types[$data['type']] : '';
    }
    
    public function getCreatetimeTextAttr($value, $data)
    {
        return date('Y-m-d H:i:s', $data['createtime']);
    }
}